package com.alt.www.sort;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @author 新技术软件：汪洋
 */
public class Solution {
    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner scan = new Scanner(System.in);
        int rowLength = 6;
        List<String> array = new ArrayList<String>();
        for(int r=0;r<rowLength;r++){
            array.add(scan.nextLine());
        }
        int clomnLength = array.get(0).split(" ").length;
        int[][] theAarry = new int[rowLength][clomnLength];
        for(int i=0;i<rowLength;i++){
            String[] teamp = array.get(i).split(" ");
            for(int j=0;j<clomnLength;j++){
                theAarry[i][j] = Integer.parseInt(teamp[j]);
            }
        }
        int maxSum = 0;
        for(int i=0;i<rowLength;i++){
            for(int j=0;j<clomnLength;j++){
                int result = calculateMax(theAarry, i, j, rowLength, clomnLength , maxSum);
                if(i==0&&j==0){
                    maxSum = result;
                }else{
                    if(result>maxSum){
                        maxSum = result;
                    }
                }

            }
        }
        System.out.println(maxSum);
    }
    private static int calculateMax(int[][] theAarry, int row, int beginColum, int rowLength, int clomnLength ,int maxSum){
        if(rowLength - row<3){
            return maxSum;
        }
        if(clomnLength - beginColum <3){
            return maxSum;
        }
        int sum = 0;
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i==1){
                    if(j==1){
                        sum = sum +theAarry[row + i][beginColum + j];
                    }
                }else{
                    sum = sum +theAarry[row + i][beginColum + j];
                }
            }
        }
        return sum;
    }
}
